package com.neoyr.meeting.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.neoyr.meeting.common.Result;
import com.neoyr.meeting.entity.UserDetail;
import com.neoyr.meeting.service.Imp.UserDetailImp;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Transactional
@Slf4j
@RestController
@RequestMapping("/sgin")
public class UserDetailController {
    @Autowired
    private UserDetailImp userDetailImp;

    @GetMapping("/{id}")
    public Result<UserDetail> saveDetail(@PathVariable Long id) {
        LambdaQueryWrapper<UserDetail> query = new LambdaQueryWrapper<>();
        query.eq(UserDetail::getUserId, id);
        List<UserDetail> list = userDetailImp.list(query);
        UserDetail info = list.get(0);
        info.setIsSign(1);
        userDetailImp.saveOrUpdate(info);
        return Result.success(info);


    }
}
